package Services;


/**
 * Enum permettant d'afficher tous les types services proposees en fonction
 * des transport
 * @author belli
 *
 */
public enum TypeServices {
	NBREPAS("nbrepas"), CLASSETRANSPORT("classe transport"), PROFIL("Profil"), BILLET("billet"), NBNUIT("nbnuit");
	
	private String description;
	
	private TypeServices(String description){
		this.description = description;
	}
	
	 public static TypeServices toTypeServices(String profil) {
	    	profil = profil.toUpperCase().replace(" ", "");
	    	TypeServices retour = null;
	        try {
	            retour = Enum.valueOf(TypeServices.class, profil);
	        } catch (Exception e) {
	            retour = TypeServices.PROFIL;
	        }
	        return retour;
	    }

		/**
	     * Print all valid commands to System.out.
	     */
	    public static void showAll() {
	    	TypeServices[] tableProfil = TypeServices.values();
	    	int entierafficher = 1;
	    	
	        for (TypeServices profil : tableProfil) {
	            System.out.println(entierafficher + " : " + profil);
	            entierafficher++;
	        }
	    }
	    
	    /**
	     * Retourner un type transport en fonction de son numero
	     * @param num
	     * @return
	     */
	    public static TypeServices choixTypeTransport(int num){
	    	num--;
	    	TypeServices[] tableTypeTransport = TypeServices.values();
	    	return tableTypeTransport[num];
	    }
	    
		/**
		 * @return Le mot correspondant a son identifiant enum
		 */
		public String toString() {
			return description;
		}
}
